package com.extension.company.common.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.webkit.WebView;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/8/7 16:14
 * 功能：
 */
public class MyWebView extends WebView {
	public float oldY;
	private int t;
	private float oldX;

	public MyWebView(Context context) {
		super(context);
	}

	public MyWebView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyWebView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}


	@Override
public boolean onTouchEvent(MotionEvent ev) {

	switch (ev.getAction()) {
		case MotionEvent.ACTION_MOVE:
			float Y = ev.getY();
			float Ys = Y - oldY;
			float X = ev.getX();

			if (Ys > 0 && t == 0) {
				getParent().getParent().requestDisallowInterceptTouchEvent(false);
			}
			break;

		case MotionEvent.ACTION_DOWN:
			getParent().getParent().requestDisallowInterceptTouchEvent(true);
			oldY = ev.getY();
			oldX = ev.getX();
			break;

		case MotionEvent.ACTION_UP:
			getParent().getParent().requestDisallowInterceptTouchEvent(true);
			break;

		default:
			break;
	}
	return super.onTouchEvent(ev);
}

	@Override
	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
		this.t = t;
		super.onScrollChanged(l, t, oldl, oldt);
	}
}
